﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace ConsoleApp
{

    public delegate void Del(string message);
    class Program
    {
        static void Main(string[] args)
        {
            //Console.WriteLine("starting......");

            Person obj = new Person();
            Del d1 = obj.Method1;
            Del d2 = obj.Method2;
            Del d3 = DelegateMethod;

            //Both types of assignment are valid.

            Del allMethodsDelegate = d1 + d2;
            allMethodsDelegate += d3;

            Debug.WriteLine("starting......");
        }

        public static void DelegateMethod(string message)
        {
            System.Console.WriteLine(message);
        }


        public void MethodWithCallback(int param1, int param2, Del callback)
        {
            callback("The number is: " + (param1 + param2).ToString());
        }
    }
}
